(function() {

this.pasta = this.pasta || {};
this.pasta.util = this.pasta.util || {};

this.pasta.util.Timer = Class.extend(
{
	init : function() 
	{
		this.interval = 1000;
		this.enabled = false;
		
		this._onTimer = null;
	},
	
	doTimer : function()
	{
		if (this._onTimer != null)
			this._onTimer.callHandler(this);
	},
	
	//------------------- Setter & Getter ---------------
	
	getTimeInterval : function() 
	{
		return this.interval;
	},
	
	setTimeInterval : function(data)
	{
		this.interval = data;
	},
	
	isEnabled : function() 
	{
		return this.enable;
	},
	
	setEnabled : function(data) 
	{
		this.enabled = data;
		clearInterval(this.intervalId);
		
		if (this.enabled)
		{
			var target = this;
			this.intervalId = setInterval(function(){target.doTimer();}, this.interval);
		}
	},
	
	//---------------------- Event ---------------
	
	getOnTimer : function()
	{
		if (this._onTimer == null)
			this._onTimer = new pasta.util.EventObj();
			
		return this._onTimer;
	}
});

})();